package io.gitee.caoxiaoyu97;

import io.gitee.caoxiaoyu97.log.CxyLoggerUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

/*********************************************************
 * 文件名称：${NAME}.java
 * 系统名称：CXY自定义系统
 * 模块名称：io.gitee.caoxiaoyu97
 * 功能说明：${TODO}
 * 开发人员 @author：caoxy31978
 * 开发时间 @date：${DATE} ${TIME}
 * 修改记录：程序版本  修改日期  修改人员  修改单号  修改说明
 *********************************************************/
public class Main {
    private static final Logger logger1 = LoggerFactory.getLogger(Main.class);
    public static void main(String[] args) {

        // Logger logger1 = LoggerFactory.getLogger(Main.class);
        // logger1.error("xxx");
        ExecutorService executorService = Executors.newScheduledThreadPool(10);
        for (int i = 0; i < 3; i++) {
            int finalI = i;
            executorService.submit(()->{
                Logger logger = LoggerFactory.getLogger(Main.class);
                CxyLoggerUtils.startTransaction(logger);
                for (int i1 = 0; i1 < 10; i1++) {
                    logger.error("name:"+ finalI + " id1:" + i1);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                    }
                    logger.error("name:"+ finalI + " id2:" + i1);
                }
                CxyLoggerUtils.endTransaction(logger);
            });
        }
        executorService.shutdown();
        // CxyLoggerUtils.startTransaction(logger);
        // logger.error("111");
        // System.out.println("Hello world!");
        // logger.info("Hello, world!");
        // CxyLoggerUtils.endTransaction(logger);
    }
}